
#pragma once

#include <mmsystem.h>

const UINT MAX_MIXER_COUNT = 10;

class CMixer;

class CMixerEventReceiver
{
public:
	virtual void OnControlChanged(CMixer *pMixer, DWORD dwControlID){;}
};

typedef CList<CMixerEventReceiver *, CMixerEventReceiver *> CMixerEventReceiverList;

class CMixer
{
private:
	CMixer(UINT uMxID);
	~CMixer(void);

	const UINT m_uMixerID;
	HMIXER m_hMixer;

	UINT m_nRefCount;

	HWND m_hWnd;

	CMixerEventReceiverList m_EventReceiverList;

	static CMixer * m_pMixerArray[MAX_MIXER_COUNT];
private:
	bool Init();

	static	LRESULT CALLBACK MixerWndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
	void OnMixerMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
public:
	HMIXER GetHandle() const{ return m_hMixer;}
    static CMixer * OpenMixer(UINT uMxID = 0);
	void AddEventReceiver(CMixerEventReceiver *pReceiver);
	void RemoveEventReceiver(CMixerEventReceiver *pReciever);
	void CloseMixer();
};
